<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用水趋势图</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.4.3/echarts.min.js"></script>
    <style type="text/css">
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
        #chart {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <div id="chart"></div>
    <script type="text/javascript">
        var myChart = echarts.init(document.getElementById('chart'));
        
        function updateChart(data) {
            var option = {
                grid: {
                    top: '10%',
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                tooltip: {
                    trigger: 'axis',
                    formatter: '{b}<br />用水量: {c}L'
                },
                xAxis: {
                    type: 'category',
                    data: data.categories,
                    axisLabel: {
                        interval: 4
                    }
                },
                yAxis: {
                    type: 'value',
                    name: '用水量(L)',
                    splitLine: {
                        lineStyle: {
                            type: 'dashed'
                        }
                    }
                },
                series: [{
                    data: data.series,
                    type: 'line',
                    smooth: true,
                    symbol: 'circle',
                    symbolSize: 8,
                    itemStyle: {
                        color: '#1296db'
                    },
                    lineStyle: {
                        width: 3
                    },
                    areaStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(18,150,219,0.3)'
                        }, {
                            offset: 1,
                            color: 'rgba(18,150,219,0.1)'
                        }])
                    }
                }]
            };
            myChart.setOption(option);
        }

        window.addEventListener('resize', function() {
            myChart.resize();
        });
    </script>
</body>
</html>
